package com.scau.phradmin.business.contents.controller;

import com.scau.phradmin.business.contents.service.impl.*;
import com.scau.phradmin.domain.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.annotation.Repeatable;

@RequestMapping("/contents")

@RestController
public class ContentsController {
    @Autowired
    private HealthKnowledgeServiceImpl healthKnowledgeService;

    @Autowired
    private MedicineDataServiceImpl medicineDataService;

    @Autowired
    private HospitalServiceImpl hospitalService;

    @Autowired
    private NewsServiceImpl newsService;

    @GetMapping("/health_knowledge/selectAll")
    public Object healthKnowledgeSelectAll(@RequestParam("pages") int pages)
    {
        return healthKnowledgeService.SelectAll(pages);
    }

    @GetMapping("/health_knowledge/selectById")
    public Object healthKnowledgeSelectById(@RequestParam("id") Integer id)
    {
        return healthKnowledgeService.SelectById(id);
    }

    @PostMapping("/health_knowledge/add")
    public boolean healthKnowledgeAdd(HealthKnowledge healthKnowledge){
        return healthKnowledgeService.Add(healthKnowledge);
    }

    @GetMapping("/medicine/selectAll")
    public Object medicineSelectAll(@RequestParam("pages") int pages)
    {
        return medicineDataService.SelectAll(pages);
    }

    @GetMapping("/medicine/selectById")
    public Object medicineSelectById(@RequestParam("id") Integer id)
    {
        return medicineDataService.SelectById(id);
    }

    @PostMapping("/medicine/add")
    public boolean medicineAdd(MedicineData medicineData){
        return medicineDataService.Add(medicineData);
    }

    @PostMapping("/medicine/update")
    public boolean medicineUpdate(MedicineData medicineData){
        return medicineDataService.update(medicineData);
    }


    @GetMapping("/hospital/selectAll")
    public Object hospitalSelectAll(@RequestParam("pages") int pages)
    {
        return hospitalService.SelectAll(pages);
    }

    @GetMapping("/hospital/selectById")
    public Object hospitalSelectById(@RequestParam("id") Integer id)
    {
        return hospitalService.SelectById(id);
    }

    @PostMapping("/hospital/add")
    public boolean hospitalAdd(Newhospital hospital){
        return hospitalService.Add(hospital);
    }

    @PostMapping("/hospital/update")
    public boolean hospitalUpdate(Newhospital newhospital){
        return hospitalService.update(newhospital);
    }

    @PostMapping("/hospital/delete")
    public boolean hospitalDelete(@RequestParam("id") Long id){
        return hospitalService.delete(id);
    }


    @PostMapping("news/add")
    public boolean newsAdd(News news){
        return newsService.Add(news);
    }

    @GetMapping("/news/selectById")
    public Object newsSelectById(@RequestParam("newsId") Integer id)
    {
        return newsService.SelectById(id);
    }

    @PostMapping("/news/update")
    public boolean newsUpdate(News news){
        return newsService.update(news);
    }
}
